package org.mspring.mlog.dao.impl;

import org.mspring.mlog.dao.AlbumDao;
import org.mspring.mlog.entity.Album;
import org.mspring.platform.dao.hibernate.GenericDao;
import org.springframework.stereotype.Repository;

/**
 *
 * @author Gao Youbo
 * @since 2014-01-11
 */
@Repository
public class AlbumDaoImpl extends GenericDao<Album, Long> implements AlbumDao {

    @Override
    public int getAlbumPhotoCount(long albumId) {
        int count = 0;
        Object obj = getHibernateTemplate().uniqueResult("select count(*) from Photo photo where photo.album.id = ?", albumId);
        if (obj != null) {
            count = Integer.parseInt(obj.toString());
        }
        return count;
    }

}
